package com.frank.wcld.zcgbxx.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.wcld.zcgbxx.domain.WcldZcgbxx;
import com.frank.wcld.zcgbxx.service.IWcldZcgbxxService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 中层以上干部信息Controller
 * 
 * @author frank
 * @date 2025-08-27
 */
@Controller
@RequestMapping("/wcld/zcgbxx")
public class WcldZcgbxxController extends BaseController
{
    private String prefix = "wcld/zcgbxx";

    @Autowired
    private IWcldZcgbxxService wcldZcgbxxService;

    @RequiresPermissions("wcld:zcgbxx:view")
    @GetMapping()
    public String zcgbxx()
    {
        return prefix + "/zcgbxx";
    }

    /**
     * 查询中层以上干部信息列表
     */
    @RequiresPermissions("wcld:zcgbxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WcldZcgbxx wcldZcgbxx)
    {
        startPage();
        List<WcldZcgbxx> list = wcldZcgbxxService.selectWcldZcgbxxList(wcldZcgbxx);
        return getDataTable(list);
    }

    /**
     * 导出中层以上干部信息列表
     */
    @RequiresPermissions("wcld:zcgbxx:export")
    @Log(title = "中层以上干部信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WcldZcgbxx wcldZcgbxx)
    {
        List<WcldZcgbxx> list = wcldZcgbxxService.selectWcldZcgbxxList(wcldZcgbxx);
        ExcelUtil<WcldZcgbxx> util = new ExcelUtil<WcldZcgbxx>(WcldZcgbxx.class);
        return util.exportExcel(list, "中层以上干部信息数据");
    }

    /**
     * 新增中层以上干部信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存中层以上干部信息
     */
    @RequiresPermissions("wcld:zcgbxx:add")
    @Log(title = "中层以上干部信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WcldZcgbxx wcldZcgbxx)
    {
        wcldZcgbxx.setCreateBy(getLoginName());
        return toAjax(wcldZcgbxxService.insertWcldZcgbxx(wcldZcgbxx));
    }

    /**
     * 修改中层以上干部信息
     */
    @RequiresPermissions("wcld:zcgbxx:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WcldZcgbxx wcldZcgbxx = wcldZcgbxxService.selectWcldZcgbxxById(id);
        mmap.put("wcldZcgbxx", wcldZcgbxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存中层以上干部信息
     */
    @RequiresPermissions("wcld:zcgbxx:edit")
    @Log(title = "中层以上干部信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WcldZcgbxx wcldZcgbxx)
    {
        wcldZcgbxx.setUpdateBy(getLoginName());
        return toAjax(wcldZcgbxxService.updateWcldZcgbxx(wcldZcgbxx));
    }

    /**
     * 删除中层以上干部信息
     */
    @RequiresPermissions("wcld:zcgbxx:remove")
    @Log(title = "中层以上干部信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wcldZcgbxxService.deleteWcldZcgbxxByIds(ids));
    }
}
